package com.iespring.controller.admin.promotion;

import com.iespring.bean.admin.promotion.bo.MallAdBo;
import com.iespring.bean.admin.promotion.bo.MallAdForUpdateBo;
import com.iespring.bean.admin.promotion.po.MallAd;
import com.iespring.bean.common.BasePageInfo;
import com.iespring.bean.common.BaseRespVo;
import com.iespring.bean.common.CommonData;
import com.iespring.service.poromotion.PromotionAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author:ZhangShuPeng
 * @Date:2022/12/28/16:43
 * @Description:
 */
@RestController
@RequestMapping("admin/ad")
public class AdController {

    @Autowired
    PromotionAdService promotionAdService;


    //page=1&limit=20&sort=add_time&order=desc
    @RequestMapping("list")
    public BaseRespVo list(BasePageInfo info, String name, String content) {

        CommonData<MallAd> data = promotionAdService.list(info, name, content);

        return BaseRespVo.ok(data);
    }

    @RequestMapping("create")
    public BaseRespVo create(@RequestBody MallAdBo mallAdBo) {

        BaseRespVo baseRespVo = promotionAdService.create(mallAdBo);


        return baseRespVo;
    }


    @RequestMapping("update")
    public BaseRespVo update(@RequestBody MallAdForUpdateBo mallAdForUpdateBo) {

        BaseRespVo baseRespVo = promotionAdService.update(mallAdForUpdateBo);

        return baseRespVo;
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MallAd mallAd) {

        int rows = promotionAdService.delete(mallAd);
        BaseRespVo baseRespVo = BaseRespVo.ok(rows);

        return baseRespVo;
    }

}
